Adding some more judges, here and there.
[and.git] / UVa / 10019 - Funny encryption method / 10019.cpp
blobaefa68c43d26c2351fc21c4fdf0941e5add6494a
1 #include <stdio.h>
2 #include <iostream>
4 using namespace std;
6 int main(int argc, char *argv[])
8 int casos;
9 scanf("%d", &casos);
10 while (casos--){
11 int x1, x2, temp, temp2;
12 scanf("%x",&x2); //<---- read number in hexdecimal system(i.e. 265)
13 //en x2 queda en hexadecimal, ahora convertirlo a decimal.
14 temp2 = x1 = 0;
15 temp = x2;
16 while (temp > 0){ //Convierto a decimal pero con la cifra menos significativa a la izquierda
17 temp2 = temp2 * 10 + temp % 16;
18 temp /= 16;
20 while (temp2 > 0){ //Invierto para que quede con cifra menos significativa a la derecha
21 x1 = x1 * 10 + temp2 % 10;
22 temp2 /= 10;
24 //Aqui en x1 y en x2 esta procesado correctamente el num en decimal.
25 int b = 0;
26 temp2 = 0;
27 temp = x1;
28 while (temp > 0){
29 temp2 = temp2 * 10 + temp % 2;
30 temp /= 2;
32 while (temp2 > 0){ //Invierto para que quede con cifra menos significativa a la derecha
33 b = b * 10 + temp2 % 10;
34 temp2 /= 10;
36 int b1 = 0;
37 while (b){
38 if (b % 10 == 1)
39 b1++;
40 b /= 10;
42 printf("%d ", b1);
43 b = 0;
44 temp2 = 0;
45 temp = x2;
46 while (temp > 0){
47 temp2 = temp2 * 10 + temp % 2;
48 temp /= 2;
50 while (temp2 > 0){ //Invierto para que quede con cifra menos significativa a la derecha
51 b = b * 10 + temp2 % 10;
52 temp2 /= 10;
54 b1 = 0;
55 while (b){
56 if (b % 10 == 1)
57 b1++;
58 b /= 10;
60 printf("%d\n", b1);
62 return 0;